package cn.lj.springboot.service;

import cn.lj.springboot.mapper.UserMapper;
import cn.lj.springboot.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class UserService {


    @Autowired
    private UserMapper userMapper;

    public User queryUserById(Long id){
        return this.userMapper.selectByPrimaryKey(id);
    }

    @Transactional
    public void deleteById(Long id){
        this.userMapper.deleteByPrimaryKey(id);
    }


    public List<User> queryUserAll() {
        return this.userMapper.selectAll();
    }

    public List<User> queryUserAll1(Long id) {
        User user = new User();
        user.setId(id);
        List<User> users = this.userMapper.select(user);

        return users;
    }


}
